package com.worthtech.billportal.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.worthtech.billportal.bean.BillDetail;
import com.worthtech.billportal.bean.BillMaster;
import com.worthtech.billportal.exception.SCException;
import com.worthtech.billportal.form.BillPayReceiveForm;
import com.worthtech.billportal.service.BillService;

public class BillPayReceive extends BaseAction {

	private BillService billService;
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		BillPayReceiveForm billPayReceiveForm = (BillPayReceiveForm)form;
		if ("update".equals(billPayReceiveForm.getAction())) {
			BillMaster billMaster = this.getBillService().getBillByBillNo(billPayReceiveForm.getBillNo());
			BillDetail billDetail = billMaster.getBillDetail();
			billMaster.setPayStatus(billPayReceiveForm.getPayStatus());
			billDetail.setBankcard(billPayReceiveForm.getBankCard());
			try {
				this.getBillService().updateBill(billMaster);
			} catch (SCException sce) {
				return mapping.findForward("error");
			} catch (Exception e) {
				return mapping.findForward("error");
			}
		}
		return null;
	}
	public BillService getBillService() {
		return billService;
	}
	public void setBillService(BillService billService) {
		this.billService = billService;
	}
	
}
